Skip to content

Plumb context through libs/git#4716

Merged
pietern merged 1 commit intomainfrom
pieter.noordhuis/git-ctx-plumbing
Mar 12, 2026
Merged

Plumb context through libs/git#4716
pietern merged 1 commit intomainfrom
pieter.noordhuis/git-ctx-plumbing

Conversation

@pietern
Copy link
Contributor

@pietern pietern commented Mar 12, 2026

Summary

  • Thread context.Context through the libs/git package's public API so that os.UserHomeDir and os.Getenv calls use context-aware equivalents (env.UserHomeDir, env.Get)
  • Resolve XDG_CONFIG_HOME once in newConfig and store on the config struct, eliminating duplication between globalGitConfig and defaultCoreExcludesFile
  • Follow-up to Use env.UserHomeDir(ctx) instead of os.UserHomeDir() #4654

🤖 Generated with Claude Code

…ions

Thread `context.Context` through the git package's public API
(`NewRepository`, `NewView`, `NewViewAtRoot`, `NewFileSet`,
`NewFileSetAtRoot`) so that `os.UserHomeDir` and `os.Getenv` calls can
be replaced with their context-aware equivalents (`env.UserHomeDir`,
`env.Get`). This makes home directory and XDG_CONFIG_HOME resolution
overridable through context, improving testability.

XDG_CONFIG_HOME is resolved once in `newConfig` and stored on the
`config` struct, eliminating the previous duplication between
`globalGitConfig` and `defaultCoreExcludesFile`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Mar 12, 2026

Commit: 92ac08b

Run: 22991637094

Env 🟨​KNOWN 🔄​flaky 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
🟨​ aws linux 7 1 7 268 781 6:26
🟨​ aws windows 7 1 7 270 779 5:41
🔄​ aws-ucws linux 2 7 7 364 696 6:28
🔄​ aws-ucws windows 2 7 7 366 694 5:48
💚​ azure linux 2 9 271 779 5:54
💚​ azure windows 2 9 273 777 5:11
🔄​ azure-ucws linux 2 1 9 369 692 8:06
🔄​ azure-ucws windows 2 1 9 371 690 6:09
💚​ gcp linux 2 9 267 782 5:15
💚​ gcp windows 2 9 269 780 4:58
16 interesting tests: 7 KNOWN, 7 SKIP, 2 flaky
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
🟨​ TestAccept 🟨​K 🟨​K 💚​R 🔄​f 💚​R 💚​R 💚​R 🔄​f 💚​R 💚​R
🙈​ TestAccept/bundle/resources/permissions 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions 🟨​K 🟨​K 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions 🟨​K 🟨​K 💚​R 💚​R 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct 🟨​K 🟨​K 💚​R 💚​R
🟨​ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform 🟨​K 🟨​K 💚​R 💚​R
🙈​ TestAccept/bundle/resources/postgres_branches/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/update_protected 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_branches/without_branch_id 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/postgres_endpoints/recreate 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/synced_database_tables/basic 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🔄​ TestAccept/ssh/connect-serverless-gpu 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s 🔄​f 🔄​f 🙈​s 🙈​s
🔄​ TestAccept/ssh/connection 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R 🔄​f 💚​R 💚​R 💚​R
Top 20 slowest tests (at least 2 minutes):
duration env testname
3:49 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:15 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:14 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:14 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:12 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:11 azure windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:06 gcp windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:05 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:02 gcp linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:54 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:48 aws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:43 aws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:39 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:38 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:34 aws-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:32 aws-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:29 azure linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:08 azure-ucws linux TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:06 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:00 azure-ucws windows TestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct

Copy link
Member

@simonfaltum simonfaltum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Agent Swarm Review] Verdict: Approved

  • 0 Critical
  • 0 Major
  • 0 Gap (blocking)
  • 0 Nit
  • 2 Suggestion

See inline comments for details.

@simonfaltum
Copy link
Member

[Agent Swarm Review] [Gap (Suggestion)] Tests do not verify context-aware env overrides

Updated tests pass t.Context() but never set context-backed env overrides (env.WithUserHomeDir, env.Set). The suite would stay green if ctx were accidentally dropped at any call site.

The forbidigo linter guards against os.UserHomeDir regressions, and this is mechanical plumbing in a series where the env package already tests its own contract, so this is non-blocking.

Suggestion: Add one focused test that sets HOME/XDG_CONFIG_HOME via env overrides on context, then verifies globalGitConfig or NewRepository uses those overrides.

@simonfaltum
Copy link
Member

[Agent Swarm Review] [Gap (Suggestion)] os.Getenv not covered by forbidigo linter (pre-existing)

forbidigo rules forbid os.UserHomeDir but not os.Getenv. This PR replaces os.Getenv("XDG_CONFIG_HOME") with env.Get(ctx, ...), but there is no linter rule preventing future reintroduction of bare os.Getenv calls. Not a flaw in this PR, but a gap it exposes.

Suggestion: Consider adding a forbidigo rule for os.Getenv (pointing to env.Get(ctx, ...)) in a companion or follow-up change.

@pietern pietern added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 116ec17 Mar 12, 2026
18 checks passed
@pietern pietern deleted the pieter.noordhuis/git-ctx-plumbing branch March 12, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants